//
//  ApplyWithdrawViewController.m
//  share_business
//
//  Created by baidufz on 2017/9/12.
//  Copyright © 2017年 wyl. All rights reserved.
//

#import "ApplyWithdrawViewController.h"
#import "UICollectionView+RegisterCell.h"
#import "CommonAmountHeaderCell.h"
#import "ApplyWithdrawMiddleCell.h"
#import "ApplyWithdrawBottomCell.h"
#import "SpaceCell.h"
#import "WithdrawDetailViewController.h"

#define ScreenWidth  [UIScreen mainScreen].bounds.size.width
@interface ApplyWithdrawViewController () <UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>

@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;


@end

@implementation ApplyWithdrawViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self registerCells];
    [self initApplyWithdraw];
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    self.navigationItem.title = @"申请提现";
    [self topRightItemButton:nil title:@"明细"];

}

- (void)rightAction:(UIButton *)button {
    [self.navigationController pushViewController:[WithdrawDetailViewController new] animated:YES];
}

- (void)registerCells {
    [_collectionView registerHeaderCell:[CommonAmountHeaderCell class]];
    [_collectionView registerHeaderCell:[ApplyWithdrawMiddleCell class]];
    [_collectionView registerHeaderCell:[ApplyWithdrawBottomCell class]];
    [_collectionView registerFooterCell:[SpaceCell class]];
    
}

- (void)initApplyWithdraw {
    _collectionView.dataSource = self;
    _collectionView.delegate = self;
}

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 3;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 0;
}

- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
    if ([kind isEqualToString:UICollectionElementKindSectionHeader] && indexPath.section == 0) {
        CommonAmountHeaderCell *header = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:NSStringFromClass([CommonAmountHeaderCell class]) forIndexPath:indexPath];
        
        return header;
    } else if ([kind isEqualToString:UICollectionElementKindSectionHeader] && indexPath.section == 1) {
        ApplyWithdrawMiddleCell *header = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:NSStringFromClass([ApplyWithdrawMiddleCell class]) forIndexPath:indexPath];
        
        return header;
    } else if ([kind isEqualToString:UICollectionElementKindSectionHeader] && indexPath.section == 2) {
        ApplyWithdrawBottomCell *header = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:NSStringFromClass([ApplyWithdrawBottomCell class]) forIndexPath:indexPath];
        
        return header;
    } else if ([kind isEqualToString:UICollectionElementKindSectionFooter]) {
        return [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:NSStringFromClass([SpaceCell class]) forIndexPath:indexPath];
    }
    
    return nil;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    return  nil;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
    CGSize size = CGSizeMake(0, 0);
    if (section == 0) {
        size = CGSizeMake(ScreenWidth, 125);
    } else if (section == 1) {
        size = CGSizeMake(ScreenWidth, 196);
    } else if (section == 2) {
        size = CGSizeMake(ScreenWidth, 91);
    }
    return size;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section {
    return CGSizeMake(ScreenWidth, 10);
}

- (IBAction)applyWithdraw:(id)sender {
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
